# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=dust
pkgver=0.8.0
pkgrel=0
pkgdesc="A more intuitive version of du in Rust"
url="https://github.com/bootandy/dust"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le"  # limited by rust/cargo
license="Apache-2.0"
makedepends="cargo"
options="net"
source="https://github.com/bootandy/dust/archive/v$pkgver/dust-$pkgver.tar.gz"

case "$CARCH" in
	# Some test fail on CI builders (see #/27645).
	armhf | armv7) options="!check";;
esac

prepare() {
	default_prepare

	# Optimize binary for size (2.5 -> 1.6 MiB).
	cat >> Cargo.toml <<-EOF

		[profile.release]
		codegen-units = 1
		lto = true
		opt-level = "z"
		panic = "abort"
	EOF

	cargo fetch --locked
}

build() {
	cargo build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	cargo install --locked --offline --path . --root="$pkgdir/usr"
	rm "$pkgdir"/usr/.crates*
}

sha512sums="
86285862e642d3c5655ab4f37cb239acf384ff7c519cbda31f5596b017817130bd4e9840b2d5ae993e22cec5c43c1ab468ede4e8004696c9f76c1015afc294fd  dust-0.8.0.tar.gz
"
